have configure conditionally set rpath.
authortsteven4 <tsteven4@gmail.com>
Tue, 9 Oct 2018 18:47:42 +0000 (12:47 -0600)
committertsteven4 <tsteven4@gmail.com>
Tue, 9 Oct 2018 18:47:42 +0000 (12:47 -0600)
this may be necessary when using a Qt installation
that was not provided by the system.

configure
configure.ac

index 4ae4d2c45e91f8f77f9bb36e8d7123f3f963dba4..061f9c0d663f8d9f086739456abe6979310d4c1f 100755 (executable)
--- a/configure
+++ b/configure
@@ -6044,6 +6044,7 @@ fi
 
                OSJEEPS=jeeps/gpslibusb.o
                CFLAGS="$OCFLAGS"
+               LDFLAGS="$OLDFLAGS"
 
 fi
  ;; #(
@@ -6153,6 +6154,7 @@ fi
 
                        OSJEEPS=jeeps/gpslibusb.o
                        CFLAGS="$OCFLAGS"
+                       LDFLAGS="$OLDFLAGS"
                        #LIBS="$LIBS `libusb-config --libs`"
 
 else
@@ -6254,6 +6256,78 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
        CPPFLAGS="$OCPPFLAGS"
+
+#      When using Qt installed on a non-system path,
+#      e.g. with Qt installed with a Qt installer from download.qt.io,
+#      we may need to add the Qt lib location to the runtime library search path.
+# we use AC_RUN_IFELSE because AC_LINK_IFELSE may pass when a different
+# Qt library is found on the runtime library search path.
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking loader paths for Qt libs" >&5
+$as_echo_n "checking loader paths for Qt libs... " >&6; }
+       OCPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS -I$QT_INC"
+       OLIBS="$LIBS"
+       LIBS="$LIBS $QT_LIBS"
+       if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+               #include <QtCore/QtGlobal>
+               #include <cstring>
+               int main () {
+               return strcmp(QT_VERSION_STR, qVersion()) != 0;
+               }
+_ACEOF
+if ac_fn_cxx_try_run "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: rpath not needed" >&5
+$as_echo "rpath not needed" >&6; }
+else
+  OLDFLAGS="$LDFLAGS"
+               LDFLAGS="$LDFLAGS -Wl,-rpath,$($QMAKE -query QT_INSTALL_LIBS)"
+               if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+                       #include <QtCore/QtGlobal>
+                       #include <cstring>
+                       int main () {
+                       return strcmp(QT_VERSION_STR, qVersion()) != 0;
+                       }
+_ACEOF
+if ac_fn_cxx_try_run "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: rpath required" >&5
+$as_echo "rpath required" >&6; }
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "loader cannot find Qt library
+See \`config.log' for more details" "$LINENO" 5; }
+                       LDFLAGS="$OLDFLAGS"
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+       CPPFLAGS="$OCPPFLAGS"
+       LIBS="$OLIBS"
+
  ;;
 esac
 
index 455c1db0da9b1ae23abd8ef9057a3dab935cfe33..d9184c4aced31d13f51ebf3b5e0959d04a23c619 100644 (file)
@@ -265,6 +265,7 @@ AS_CASE(["$target"], [*-*-cygwin* | *-*-mingw32*], [
                )
                OSJEEPS=jeeps/gpslibusb.o
                CFLAGS="$OCFLAGS"
+               LDFLAGS="$OLDFLAGS"
        ])
 ], [
        GBSER=gbser_posix.o
@@ -288,6 +289,7 @@ AS_CASE(["$target"], [*-*-cygwin* | *-*-mingw32*], [
                        )
                        OSJEEPS=jeeps/gpslibusb.o
                        CFLAGS="$OCFLAGS"
+                       LDFLAGS="$OLDFLAGS"
                        #LIBS="$LIBS `libusb-config --libs`"
                ], [
                        OSJEEPS=jeeps/gpsusbstub.o
@@ -346,6 +348,40 @@ AS_CASE(["$target"], [*-*-darwin*], [
                        )]
                )
        CPPFLAGS="$OCPPFLAGS"
+
+#      When using Qt installed on a non-system path,
+#      e.g. with Qt installed with a Qt installer from download.qt.io,
+#      we may need to add the Qt lib location to the runtime library search path.
+# we use AC_RUN_IFELSE because AC_LINK_IFELSE may pass when a different
+# Qt library is found on the runtime library search path.
+       AC_MSG_CHECKING(loader paths for Qt libs)
+       OCPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS -I$QT_INC"
+       OLIBS="$LIBS"
+       LIBS="$LIBS $QT_LIBS"
+       AC_RUN_IFELSE([AC_LANG_SOURCE([
+               #include <QtCore/QtGlobal>
+               #include <cstring>
+               int main () {
+               return strcmp(QT_VERSION_STR, qVersion()) != 0;
+               }])],
+               [AC_MSG_RESULT(rpath not needed)],
+               [OLDFLAGS="$LDFLAGS"
+               LDFLAGS="$LDFLAGS -Wl,-rpath,$($QMAKE -query QT_INSTALL_LIBS)"
+               AC_RUN_IFELSE([AC_LANG_SOURCE([
+                       #include <QtCore/QtGlobal>
+                       #include <cstring>
+                       int main () {
+                       return strcmp(QT_VERSION_STR, qVersion()) != 0;
+                       }])],
+                       [AC_MSG_RESULT(rpath required)],
+                       [AC_MSG_FAILURE(loader cannot find Qt library)
+                       LDFLAGS="$OLDFLAGS"]
+                       )]
+               )
+       CPPFLAGS="$OCPPFLAGS"
+       LIBS="$OLIBS"
+
 ])
 
 AC_MSG_CHECKING([for random stuff to make you feel better])